package T4.EjemplosDeIO;


import java.io.*;

public class Ejemplo5 {

    public static void main(String[] args) {

        File file = new File("C:/datos.txt");
        FileInputStream fileInputStream = null;
        InputStreamReader inputStreamReader = null;
        BufferedReader bufferedReader = null;
        PrintWriter printWriter = null;
        try {
            printWriter = new PrintWriter(file);
            printWriter.println(25);
            printWriter.println(2.5);
            printWriter.println(true);
            printWriter.println(3.6F);
            printWriter.close();
            fileInputStream = new FileInputStream(file);
            inputStreamReader = new InputStreamReader(fileInputStream);
            bufferedReader = new BufferedReader(inputStreamReader);
            int entero = Integer.parseInt(bufferedReader.readLine());
            double realDoble = Double.parseDouble(bufferedReader.readLine());
            boolean logico = Boolean.parseBoolean(bufferedReader.readLine());
            float real = Float.parseFloat(bufferedReader.readLine());
            System.out.println(entero + " " + realDoble + " " + logico + " " + real);

        } catch (IOException ex) {
            System.out.println("Error durante el proceso");
            ex.printStackTrace();
        } finally {
            try {
                if (fileInputStream != null) {
                    fileInputStream.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            try {
                if (inputStreamReader != null) {
                    inputStreamReader.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            try {
                if (bufferedReader != null) {
                    bufferedReader.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            if (printWriter != null) {
                printWriter.close();
            }
        }
    }
}